package com.teatang.tadmin.sysmenu.controller;

import com.teatang.tadmin.core.controller.BasePageController;
import com.teatang.tadmin.sysmenu.service.SysMenuService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class SysMenuPageController extends BasePageController {
    @Autowired
    private SysMenuService sysMenuService;

    @RequiresPermissions("sys:menu-page:index")
    @GetMapping("/sys-menu-page/index.html")
    public String index() {
        return "sys-menu/index";
    }

    @RequiresPermissions("sys:menu-page:add")
    @GetMapping("/sys-menu-page/add.html")
    public String add() {
        return "sys-menu/add";
    }

    @RequiresPermissions("sys:menu-page:edit")
    @GetMapping("/sys-menu-page/edit.html/{id}")
    public String edit(@PathVariable("id") int id, Model model) {
        model.addAttribute("model", sysMenuService.getSysMenuById(id));
        return "sys-menu/edit";
    }
}
